<template>
  <div class="app-container p-rel">
    <div class="container-title">统计</div>
    <div>
      <div>
        数量统计： {{physicianCountDto.count}}
      </div>
      <div>
        多点执业医师统计：{{physicianCountDto.multiPointCount}}
        多点执业医师统计百分比：{{physicianCountDto.multiPointPercent}}
      </div>
      <div>
        多点执业未备案统计：{{physicianCountDto.notMultiPointCount}}
        多点执业未备案统计百分比：{{physicianCountDto.notMultiPointPercent}}
      </div>

    </div>

    <div class="container-title" style="margin-top: 20px">查询</div>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="85px">
      <el-row :gutter="15">
        <el-col :lg="2" :xl="6">
          <el-form-item label="医生姓名" prop="physicianName" label-width="150px">
            <el-input
              v-model="queryParams.physicianName"
              placeholder="请输入医生姓名"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="2" :xl="6">
          <el-form-item label="证件号码" prop="identityNumber">
            <el-input
              v-model="queryParams.identityNumber"
              placeholder="请输入证件号码"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="2" :xl="6">
          <el-form-item label="执业注册证书编号" prop="certificateNumber" label-width="150px">
            <el-input
              v-model="queryParams.certificateNumber"
              placeholder="请输入执业注册证书编号"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
          <el-form-item label="执行范围" prop="practicingRange">
            <el-input
              v-model="queryParams.practicingRange"
              placeholder="请输入执行范围"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
          <el-form-item label="多点执业是否注册" prop="multiPoint" label-width="150px">
            <el-select v-model="queryParams.multiPoint" placeholder="请选择多点执业是否注册" clearable >
              <el-option
                v-for="dict in dict.type.multi_point_type"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
            <el-button type="primary" icon="" size="" @click="handleQuery">搜索</el-button>
            <el-button icon="" size="" @click="resetQuery">重置</el-button>
        </el-col>
      </el-row>
    </el-form>

<!--    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          plain
          size="mini"
          @click="handleAdd"
          v-hasPermi="['medical:physician:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          plain
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['medical:physician:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          plain
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['medical:physician:remove']"
        >删除</el-button>
      </el-col>
      &lt;!&ndash;<el-col :span="1.5">
       <el-button
          plain
          size="mini"
          @click="handleExport"
          v-hasPermi="['medical:physician:export']"
        >导出</el-button>
      </el-col>&ndash;&gt;
      &lt;!&ndash;<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>&ndash;&gt;
    </el-row>-->

    <el-table v-loading="loading" :data="physicianList">
      <el-table-column type="index" width="55" align="center" label="序号"/>
      <el-table-column label="医生姓名" align="center" prop="physicianName" />
      <el-table-column label="医师类型" align="center" prop="physicianType" />
      <el-table-column label="身份证号码" align="center" prop="identityNumber" />
      <el-table-column label="证书编号" align="center" prop="certificateNumber" />
      <el-table-column label="执业类别" align="center" prop="practicingType" />
      <el-table-column label="执行范围" align="center" prop="practicingRange" />
      <el-table-column label="主要执业机构" align="center" prop="dainong" />
      <el-table-column label="签发日期" align="center" prop="issueDate" />
      <el-table-column label="多点执业是否注册" align="center" prop="multiPoint">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.multi_point_type" :value="scope.row.multiPoint"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
              size="mini"
              type="text"
              @click="selectQuery(scope.row)"
          >查看详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listPhysician, physicianCount, getPhysicianById } from "@/api/zhangping/physician";
export default {
  name: "Physician",
  dicts: ['multi_point_type', 'sys_user_sex'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 医师执业注册信息表格数据
      physicianList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        physicianName: null,
        physicianType: null,
        identityNumber: null,
        certificateNumber: null,
        practicingType: null,
        practicingRange: null,
        enterpriseName: null,
        creditCode: null,
        issueDate: null,
        multiPoint: null,
        sex: null,
        photo: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      detailForm:{},
      isEdit:false,
      editVisible:false,
      physicianCountDto:{
        //数量统计
        count: '',
        //点执业医师统计
        multiPointCount: '',
        //多点执业医师统计百分比
        multiPointPercent: '',
        //多点执业未备案统计
        notMultiPointCount: '',
        //多点执业未备案统计百分比
        notMultiPointPercent: '',
      }
    };
  },
  created() {
    this.getList();
    this.getPhysicianCount();
  },
  methods: {
    /** 查询医师执业注册信息列表 */
    getList() {
      this.loading = true;
      listPhysician(this.queryParams).then(response => {
        this.physicianList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 查询医师执业注册信息列表统计 */
    getPhysicianCount() {
      physicianCount().then(response => {
        this.physicianCountDto = response.data
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        physicianName: null,
        physicianType: null,
        identityNumber: null,
        certificateNumber: null,
        practicingType: null,
        practicingRange: null,
        enterpriseName: null,
        creditCode: null,
        issueDate: null,
        multiPoint: null,
        sex: null,
        photo: null,
        createId: null,
        createBy: null,
        createTime: null,
        updateId: null,
        updateBy: null,
        updateTime: null,
        delFlag: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    // 查看详情
    selectQuery(row){
      getPhysicianById({id: row.id}).then(response => {
        console.log("response", response)
      });

      const obj = {
        path: '/zp/physician/detail',
        query: {
          id: row.id
        }
      }
      this.$router.push(obj);
    }

  }
};
</script>
